clKeyPad::clKeyPad() {
	KeyPadDDR	=	0x0f;
	String[0]	=	'\0';
}

const char clKeyPad::KeyPadCharMatrix[KeyPadButtonsCount] =	{'1', '2', '3', 'a', '4', '5', '6', 'b', '7', '8', '9', 'c', '*',
'0', '#', 'd'};

inline void clKeyPad::FillCheckedMatrix(char  lPINs, unsigned char const *lSelectedPin){
	Buttons.Row[*lSelectedPin].bits	= (lPINs >> 4);
}

void clKeyPad::KeyPadScan(){
	unsigned char SelectedPin = 0x08, Row = 0;
	
	do {
		KeyPadPORT	&= SelectedPin;
		FillCheckedMatrix(KeyPadPIN, &Row);
		Row++;
	} while (SelectedPin >>= 1);
	
	FillString();
}

inline void clKeyPad::FillString(void){
	unsigned char	ButtonIndex = 0;
	char			*pString = String;

	for (ButtonIndex = 0; ButtonIndex < KeyPadButtonsCount; ButtonIndex++)
	{
		if (Buttons.Bits[ButtonIndex]) {
			*(pString) = KeyPadCharMatrix[ButtonIndex];
			pString++;
		};
	}
	
	*(pString) = '\0';
}
